package org.example.springbirthday.mapper;

import org.apache.ibatis.annotations.*;
import org.example.springbirthday.model.BlessInfo;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/8/7
 * Time: 15:42
 */
@Mapper
public interface BlessInfoMapper {

    @Select("select content,user_name,create_time_status from bless_info limit #{size} offset #{offset}")
    List<BlessInfo> getBlessInfoListByPageAndSize(Integer offset, Integer size);

    @Insert("insert into bless_info (content,user_id,user_name,create_time_status,update_time_status) values (#{content},#{userId},#{userName},#{createTimeStatus},#{updateTimeStatus})")
    Integer addBlessInfo(BlessInfo blessInfo);

    @Delete("delete from bless_info where id = #{id}")
    Integer removeById(Integer id);

    @Select("select * from bless_info where user_id = #{userId}")
    List<BlessInfo> getBlessInfoListByUserId(Integer userId);

    @Delete("delete from bless_info where id = #{id}")
    Integer deleteBlessInfo(Integer id);

    @Update("update bless_info set content = #{content},update_time = now(),update_time_status = #{updateTimeStatus} where id = #{id}")
    Integer updateBlessInfo(BlessInfo blessInfo);

    @Update("update bless_info set user_name = #{userName} where id = #{id}")
    Integer updateUserName(BlessInfo blessInfo);

    @Select("select count from number where id = 1")
    Integer count();

    @Update("update number set count = #{count} where id = 1")
    Integer updateCount(Integer count);
}
